home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 2.5 KB | 116 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1992-93 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Programmer: Kent Sandvik
- Date: 12/14/92
- Revision comments are at the end of this file.
- ---
- TTimer is a simple timing class that could provide both 10 lap time values as well as
- final values.
- TTimer.cp contains the TTimer member functions.
- _________________________________________________________________________________________________________ */
-
- #ifndef _TIMER_
- #include "Timer.h"
- #endif
-
-
- // _________________________________________________________________________________________________________ //
- // TTimer Class definitions.
-
- // CONSTRUCTORS AND DESTRUCTORS
- #pragma segment Timer
- TTimer::TTimer()
- // Default constructor.
- {
- this->Reset();
- }
-
-
- #pragma segment Timer
- TTimer::~TTimer()
- // Default destructor -- empty for the time being.
- {
- }
-
-
- // MAIN INTERFACES
- #pragma segment Timer
- void TTimer::Start()
- // Start the timer.
- {
- fStartTick = ::TickCount();
- }
-
-
- #pragma segment Timer
- void TTimer::Stop()
- // Stop the timer.
- {
- fStopTick = ::TickCount();
- }
-
- #pragma segment Timer
- void TTimer::Reset()
- // Reset the internal count to zero.
- {
- fStartTick = fStopTick = 0;
- }
-
-
- #pragma segment Timer
- void TTimer::SetLap(short index)
- // Set a lap time, where we have 10 lap registers.
- {
- VASSERT(index < 11, ("Index is bigger than 10 = %d\n", index));
- if (index < 11)
- fLapIndex[index] = ::TickCount() - fStartTick;
- }
-
-
- #pragma segment Timer
- long TTimer::GetLap(short index)
- // Get the lap time, we have 10 lap registers.
- {
- VASSERT(index < 11, ("Index is bigger than 10 = %d\n", index));
- if (index < 11)
- return fLapIndex[index];
- else
- return 0;
- }
-
-
- #pragma segment Timer
- long TTimer::GetLap()
- // Get a temporary lap time, independent of the registers.
- {
- long temp = ::TickCount();
- return (temp - fStartTick);
- }
-
-
- #pragma segment Timer
- long TTimer::GetTicks()
- // Get tick count from when we started the timer.
- {
- return (fStopTick - fStartTick);
- }
-
-
- #pragma segment Timer
- float TTimer::GetSeconds()
- // Get N seconds from the point of time when we started the timer.
- {
- return ((float)(fStopTick - fStartTick) / 60L);
- }
-
-
- // _________________________________________________________________________________________________________ //
-
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 12/14/92 New file
- 2 khs 1/3/93 Cleanup
- */
-